<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS三角应用-京东效果</title>
    <style>
        .box {
            position: relative;
            width: 100px;
            height: 200px;
            background-color: pink;
            margin: 50px auto;
        }

        .triangle {
            position: absolute;
            top: -20px;
            right: 0px;
            width: 0;
            height: 0;
            border: 10px solid transparent;
            border-bottom-color: green;
        }

        .box2 {
            position: relative;
            width: 200px;
            height: 50px;
            background-color: skyblue;
            margin: 100px auto;
        }

        .box2 span {
            position: absolute;
            top: 25px;
            right: -20px;
            margin-top: -10px;
            width: 0;
            height: 0;
            line-height: 0;
            font-size: 0;
            border: 10px solid transparent;
            border-left-color: green;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="triangle"></div>
    </div>
    <div class="box2">
        <span></span>
    </div>
</body>

</html>